<template>

  <div>
    <div style="margin-bottom: 20px">
      <h1>请假流程审批</h1>
    </div>

    <el-form :model="form" name="el-form-goods-category-edit-name" id="el-form-goods-category-edit-id">
      <el-form-item label="请假标题" :label-width="formLabelWidth">
        <el-input v-model="form.name"  readonly="readonly" autocomplete="off"></el-input>
      </el-form-item>

      <el-form-item label="请假事由" :label-width="formLabelWidth">
        <el-input v-model="form.detail"  readonly="readonly"   autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="申请人" :label-width="formLabelWidth">
        <el-input v-model="form.applyName" readonly="readonly"   autocomplete="off"></el-input>
      </el-form-item>

      <el-form-item label="申请时间" :label-width="formLabelWidth">
        <el-input v-model="form.applyTime"  readonly="readonly"   autocomplete="off"></el-input>
      </el-form-item>

      <el-form-item label="请假开始时间" :label-width="formLabelWidth">
        <el-input v-model="form.startDate" readonly="readonly"   autocomplete="off"></el-input>
      </el-form-item>

      <el-form-item label="请假结束时间" :label-width="formLabelWidth">
        <el-input v-model="form.endDate"  readonly="readonly"  autocomplete="off"></el-input>
      </el-form-item>



      <el-form-item label="审批意见" :label-width="formLabelWidth">
        <el-input v-model="form.opinion"   autocomplete="off"></el-input>
      </el-form-item>


    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="_cancel">取消</el-button>
      <el-button type="primary" @click="_pass">通过</el-button>
      <el-button type="primary" @click="_back">驳回</el-button>
    </div>
  </div>

</template>

<script>

  export default {

    mounted(){

      this._page();
    },
    components:{
    },
    name: "Home",
    data(){
      return {
        form:{
          name:undefined,
          detail:undefined,
          applyTime:undefined,
          startDate:undefined,
          endDate:undefined,
          opinion:undefined,
          applyName:undefined
        },
        formLabelWidth: '120px',
        currentPage:1, //初始页
        pageSize:10,    //    每页的数据
        total:0,    //    每页的数据
        getPage:[],
        columnName:[
          {prop:"name",label:"名称",width:"120",fixed:true},
          {prop:"summary",label:"商品类别描述",width:"120"},
          {prop:"ctime",label:"添加时间",width:"120"},
        ],
      }
    },
    methods:{
      handleClick(data){
        console.log(data);
      },

      _cancel(){
        this.$router.push('/workflow/process_approval')
      },

      handleSizeChange(val) {
        this.pageSize=val;
        this._page();
      },
      handleCurrentChange(val) {
        this.currentPage=val;
        this._page();
      },

      _page(){
        let businessId= this.$route.query.businessId;
        this.$http.get('/oa/leave_apply/'+businessId).then(res=>{
          let data= res.data.data;
          data.startDate=this.$dateformat(data.startDate,'yyyy-mm-dd HH:MM:ss')
          data.endDate=this.$dateformat(data.endDate,'yyyy-mm-dd HH:MM:ss')
          data.applyTime=this.$dateformat(data.applyTime,'yyyy-mm-dd HH:MM:ss')
          this.form=data;
        }).catch(err=>{
          console.log(err)
        });
      },

      _pass(){
        let taskId= this.$route.query.id;
        let businessId= this.$route.query.businessId;
        this.$http.post('/oa/leave_apply/pass?taskId='+taskId+'&businessId='+businessId+'&opinion='+this.form.opinion).then(res=>{
          let data= res.data.data;
          if (data){
            this.$message({
              type: 'success',
              message: '提交成功!'
            });
            this._cancel();
          }

        }).catch(err=>{
          console.log(err)
        });

      },

      _edit(row){
        console.log(row);
        this.$refs.goodsCategoryEditRef._open(row);
      },

      _add(){
        this.$refs.goodsCategoryEditRef._open();
      },

      _onSearch(){
          console.log('------------------------',this.forObject)
          this._page();
      }


    },
  }
</script>

<style scoped>

</style>
